package main

import (
	"fmt"

	"fawn/blog/common.in/logger"
	_ "fawn/blog/routers"
	"fawn/blog/web/controllers"
	"fawn/blog/web/dao"

	"github.com/astaxie/beego"
)

func main() {
	logDir := beego.AppConfig.String("log_dir")
	appname := beego.AppConfig.String("appname")
	runmode := beego.AppConfig.String("runmode")

	// 初始化log
	commonLogger := logger.InitLogger(runmode, fmt.Sprintf("%s/%s.log", logDir, appname), 100, 7, 30, true)

	// 引入log
	controllers.SetLogger(commonLogger)
	dao.SetLogger(commonLogger)

	// 初始化gorm
	dao.DB.Init()
	defer dao.DB.Close()

	beego.Run()
}
